package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.enums.HigherStatus;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysTenant;
import com.ruoyi.system.mapper.SysTenantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysHigherMapper;
import com.ruoyi.system.domain.SysHigher;
import com.ruoyi.system.service.ISysHigherService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 涨租管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-07-06
 */
@Service
public class SysHigherServiceImpl implements ISysHigherService
{
    @Autowired
    private SysHigherMapper sysHigherMapper;

    @Autowired
    private SysTenantMapper sysTenantMapper;

    /**
     * 查询涨租管理
     * 
     * @param higherId 涨租管理ID
     * @return 涨租管理
     */
    @Override
    public SysHigher selectSysHigherById(Long higherId)
    {
        return sysHigherMapper.selectSysHigherById(higherId);
    }

    /**
     * 查询涨租管理
     *
     * @param tenantId 涨租管理ID
     * @return 涨租管理
     */
    @Override
    public SysHigher selectSysHigherByTenantId(Long tenantId) {
        return sysHigherMapper.selectSysHigherByTenantId(tenantId);
    }

    /**
     * 查询涨租管理列表
     * 
     * @param sysHigher 涨租管理
     * @return 涨租管理
     */
    @Override
    public List<SysHigher> selectSysHigherList(SysHigher sysHigher)
    {
        return sysHigherMapper.selectSysHigherList(sysHigher);
    }

    @Override
    public List<SysHigher> selectSysHigherLogByTenantIdsList(String tenantId) {
        return sysHigherMapper.selectSysHigherLogByTenantIdsList(Convert.toStrArray(tenantId));
    }

    /**
     * 查询涨租记录列表
     *
     * @param sysHigher 涨租管理
     * @return 涨租日志集合
     */
    @Override
    public List<SysHigher> selectSysHigherLogList(SysHigher sysHigher) {
        return sysHigherMapper.selectSysHigherLogList(sysHigher);
    }


    /**
     * 查询涨租记录列表
     *
     * @param
     * @return 涨租日志集合
     */
    @Override
    public List<SysHigher> selectSysHigherLogStatList() {
        return sysHigherMapper.selectSysHigherLogStatList();
    }

    /**
     * 查询首页涨租记录列表
     *
     * @param
     */

    @Override
    public Double selectSysHigherStat(String nowDate) {
        return sysHigherMapper.selectSysHigherStat(nowDate);
    }

    /**
     * 查询首页涨租户数列表
     *
     * @param
     */
    @Override
    public List<SysHigher> selectSysHigherStatNum() {
        return sysHigherMapper.selectSysHigherStatNum();
    }


    /**
     * 新增涨租管理
     * 
     * @param sysHigher 涨租管理
     * @return 结果
     */
    @Override
    @Transactional
    public int insertSysHigher(SysHigher sysHigher)
    {
        SysTenant sysTenant = new SysTenant();
        sysTenant.setTenantId(sysHigher.getTenantId());
        sysTenant.setRisePriceStatus(HigherStatus.ALREADY.getCode());
        sysTenant.setHigherRentFee(sysHigher.getHigherRentFee().toString());
        sysTenantMapper.updateSysTenant(sysTenant);
        sysHigher.setCreateTime(DateUtils.getNowDate());
        return sysHigherMapper.insertSysHigher(sysHigher);
    }

    /**
     * 修改涨租管理
     * 
     * @param sysHigher 涨租管理
     * @return 结果
     */
    @Override
    public int updateSysHigher(SysHigher sysHigher)
    {
        sysHigher.setUpdateTime(DateUtils.getNowDate());
        return sysHigherMapper.updateSysHigher(sysHigher);
    }

    /**
     * 删除涨租管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysHigherByIds(String ids)
    {
        return sysHigherMapper.deleteSysHigherByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除涨租管理信息
     * 
     * @param higherId 涨租管理ID
     * @return 结果
     */
    @Override
    public int deleteSysHigherById(Long higherId)
    {
        return sysHigherMapper.deleteSysHigherById(higherId);
    }
}
